// index.js
// 获取应用实例
const app = getApp()

Page({
  data: {
    setting:null
  },
  loops(e){
    console.log(e.currentTarget.dataset.id)
    wx.navigateTo({
      url: '/pages/NB/NB?ids='+ e.currentTarget.dataset.id,
    })
  },
  getdata(){
    let setting = {};
    wx.cloud.database().collection('bin_inf').get().then(res=>{
      console.log(res)
      for(let i=0;i < res.data.length;i++){
        if(res.data[i].bin_num == 1 && res.data[i].bing_up){ setting['bin_1_up'] = res.data[i].bing_box.length};
        if(res.data[i].bin_num == 1 && !res.data[i].bing_up){ setting['bin_1_dow'] = res.data[i].bing_box.length};
        if(res.data[i].bin_num == 2 && res.data[i].bing_up){ setting['bin_2_up'] = res.data[i].bing_box.length};
        if(res.data[i].bin_num == 2 && !res.data[i].bing_up){ setting['bin_2_dow'] = res.data[i].bing_box.length};
        if(res.data[i].bin_num == 3 && res.data[i].bing_up){ setting['bin_3_up'] = res.data[i].bing_box.length};
        if(res.data[i].bin_num == 3 && !res.data[i].bing_up){ setting['bin_3_dow'] = res.data[i].bing_box.length};
        if(res.data[i].bin_num == 4 && res.data[i].bing_up){ setting['bin_4_up'] = res.data[i].bing_box.length};
        if(res.data[i].bin_num == 4 && !res.data[i].bing_up){ setting['bin_4_dow'] = res.data[i].bing_box.length};
      }
      console.log(setting)
      this.setData({setting:setting})
    })
    
  },
  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {
    this.getdata();
  },
  onLoad(option) {
    this.getdata();
  }
 
})
